package edu.tcc.iot.utils;

import edu.tcc.iot.domain.Product;
import edu.tcc.iot.domain.ProductInfo;
import edu.tcc.iot.domain.Shelf;
import edu.tcc.iot.domain.vo.ProductInfoVO;
import edu.tcc.iot.domain.vo.ProductVO;
import edu.tcc.iot.domain.vo.ShelfVO;

public class Parser {
	
	public static Shelf fromShelfVO(ShelfVO vo){
		return new Shelf(vo.getShelfID());
	}
	
	public static Product fromProductVO(ProductVO vo){
		ProductInfo info = new ProductInfo();
		ProductInfoVO infoVO = vo.getProductInfo();
		info.setName(infoVO.getName());
		info.setPrice(infoVO.getPrice());
		info.setQuantity(infoVO.getQuantity());
		long date = infoVO.getValidate().getTime();
		info.setValidate(new java.sql.Date(date));
		return new Product(vo.getId(), info);
	}

}
